package com.usbserial.driver;

/**
 * Supported driver chipsets. Aligns with the legacy Flutter API constants.
 */
public enum DriverType {
    AUTO(""),
    CDC("cdc"),
    CH34X("ch34x"),
    CP210X("cp210x"),
    FTDI("ftdi"),
    PL2303("pl2303");

    private final String legacyName;

    DriverType(String legacyName) {
        this.legacyName = legacyName;
    }

    public String getLegacyName() {
        return legacyName;
    }

    public static DriverType fromLegacyName(String value) {
        if (value == null || value.isEmpty()) {
            return AUTO;
        }
        for (DriverType type : values()) {
            if (type.legacyName.equalsIgnoreCase(value)) {
                return type;
            }
        }
        return AUTO;
    }
}
